<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import secureDispostitonNode from '@/api/secure/secureDispostitonNode'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  secureDispostitonNode.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  secureDispostitonNode.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_secure_dispostiton_node',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: secureDispostitonNode.getList,
  recycleApi: secureDispostitonNode.getRecycleList,
  add: {
    show: true,
    api: secureDispostitonNode.save,
    auth: ['secure:dispostitonNode:save']
  },
  edit: {
    show: true,
    api: secureDispostitonNode.update,
    auth: ['secure:dispostitonNode:update']
  },
  delete: {
    show: true,
    api: secureDispostitonNode.deletes,
    auth: ['secure:dispostitonNode:delete'],
    realApi: secureDispostitonNode.realDeletes,
    realAuth: ['secure:dispostitonNode:realDeletes']
  },
  recovery: {
    show: true,
    api: secureDispostitonNode.recoverys,
    auth: ['secure:dispostitonNode:recovery']
  },
  import: {
    show: true,
    url: 'secure/dispostitonNode/import',
    templateUrl: 'secure/dispostitonNode/downloadTemplate',
    auth: ['secure:dispostitonNode:import']
  },
  export: {
    show: true,
    url: 'secure/dispostitonNode/export',
    auth: ['secure:dispostitonNode:export']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "路线ID",
    dataIndex: "route_id",
    formType: "input",
    search: true
  },
  {
    title: "检查路线",
    dataIndex: "node_info",
    formType: "input",
    search: true
  },
  {
    title: "要求",
    dataIndex: "demand",
    formType: "input",
    search: true
  },
  {
    title: "事件描述",
    dataIndex: "incident_text",
    formType: "input",
    search: true
  },
  {
    title: "检查人",
    dataIndex: "inspect",
    formType: "input",
    search: true
  },
  {
    title: "事件图片",
    dataIndex: "incident_image",
    formType: "upload",
    type: "file",
    multiple: true,
    onlyData: true,
    returnType: "url"
  },
  {
    title: "检查结果",
    dataIndex: "inspect_status",
    formType: "select",
    search: true,
    commonRules: {
      required: true,
      message: "请输入检查结果"
    },
    dict: {
      name: "inspect_status",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
    }
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  }
])
</script>
<script> export default { name: 'secure:dispostitonNode' } </script>